import {message} from 'antd'

export const getResponse = (response: { failed: boolean; message: any; type: any }, errorCallback: (arg0: any) => void) => {
	if (response && response.failed === true) {
		if (errorCallback) {
			errorCallback(response)
		} else {
			const msg = {
				_notification: '操作失败',
				description: response.message,
			}

			switch (response.type) {
				case 'info':
					message.info(msg)

					break

				case 'warn':
					message.warning(msg)

					break

				case 'error':
				default:
					message.error(msg)

					break
			}
		}
	}
}
